String.prototype.format = function() {
	var args = arguments;
	return this.replace(/\{\{|\}\}|\{(\d+)\}/g, function(m, n) {
		if (m == "{{") {
			return "{";
		}
		if (m == "}}") {
			return "}";
		}
		return args[n];
	});
};

$(document).ready(function () {
	// Current active menu.
	var currentUrl = window.location.pathname;
	if (currentUrl != '' && currentUrl != undefined && currentUrl != '/') {
		var currentActiveA = $('#layout_menu a[href$="{0}"]'.format(currentUrl));
		if (currentActiveA != null && currentActiveA != undefined) {
			$(currentActiveA).addClass("active");

			// Get parent.
			if ($(currentActiveA).parent().tagName != 'li') {
				$($(currentActiveA).parent().parent()).removeClass('collapse');
				$($(currentActiveA).parent().parent()).addClass('in');
			}
		}
	}
});